-module(testS1).
-include_lib("records.hrl").
-export([run/0]).

run() ->
  Main = self(),
  S1 = spawn(fun()->routerc:init(1) end),
  S2 = spawn(fun()->routerc:init(2) end),
  L1_2 = spawn(fun()->routeroutputline:init(1, 10, 1.25*8000, 2, S2, 0)end),
  S1 ! {self(), {add_output, L1_2}},
  Utils = spawn(fun()->utils:server()end),
  PG = spawn(fun()->packetgenerator_exp:init(Main, 200000, 8000, 1, [1,2], S1, Utils)end),

  MaxTime = utils:get_max(1,0)+200,

  io:format("Max Time:~p~n", [MaxTime]),
  utils:sleep(2000),

  utils:run_tdm([L1_2,PG], 0, MaxTime),

  {_, Loss} = utils:results_tdm([S1]),
  {Rec, _} = utils:results_tdm([S2]),

  utils:display_results_tdm(Rec, Loss),

  utils:close_tdm([S1,S2,PG,Utils, L1_2]).

